#include <bits/stdc++.h>
// 2025/03/08
// tag:
// Author: Forever
using namespace std;
#define int long long

const int N = 100000, M = 100000;
int n, m, w[N + 1], sum[N + 1], s[N + 1];

double average(int l, int r)
{
    return (sum[r] - sum[l - 1]) * 1.0 / (r - l + 1);
}

void solve(int T)
{
    memset(sum, 0, sizeof(sum));
    memset(s, 0, sizeof(s));
    string name = "test" + to_string(T) + ".in";
    string name2 = "test" + to_string(T) + ".out";
    freopen(name.c_str(), "r", stdin);
    freopen(name2.c_str(), "w", stdout);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> w[i], sum[i] = sum[i - 1] + w[i], s[i] = s[i - 1] + w[i] * w[i];
    for (int i = 1; i <= m; i++) {
        int l, r;
        cin >> l >> r;
        double A = average(l, r);
        cout << fixed << setprecision(3) << (s[r] - s[l - 1] - A * (sum[r] - sum[l - 1]) * 2) / (r - l + 1) + A * A << endl;
    }
    fclose(stdout);
    fclose(stdin);
}

using int64 = int64_t;
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    for (int i = 6; i <= 10; i++) {
        string name = "test" + to_string(i) + ".in";
        freopen(name.c_str(), "w", stdout);
        random_device rd;
        mt19937 gen(rd());
        uniform_int_distribution<int> r(1, 1000);
        cout << N << " " << M << endl;
        for (int j = 1; j <= N; j++)
            cout << r(gen) << " ";
        cout << endl;
        uniform_int_distribution<int> dis(1, N);
        for (int j = 1; j <= M; j++){
            int a = dis(gen), b = dis(gen);
            cout << min(a, b) << " " << max(a, b) << endl;
        }
        fclose(stdout);
        solve(i);
    }
    return 0;
}